//:C07:StreambufIterator.cpp
// istreambuf_iterator & ostreambuf_iterator.
#include <algorithm>
#include <iostream>
#include <fstream>
#include <iterator>
#include "../require.h"
using namespace std;

int main(void)
{
    ifstream in("StreambufIterator.cpp");
    assure(in, "StreambufIterator.cpp");
    // Exact repressentatioin of stream:
    istreambuf_iterator<char> isb(in), end;
    ostreambuf_iterator<char> osb(cout);

    while(isb != end)
    {
        *osb++ = *isb++;    // Copy 'in' to cout
    }

    cout << endl;
    ifstream in2("StreambufIterator.cpp");
    // Strips white space:
    istream_iterator<char> is(in2), end2;
    ostream_iterator<char> os(cout);

    while(is != end2)
    {
        *os++ = *is++;
    }
    cout << endl;
}